import en from './en/index'
import zh_CN from './zh_CN/index'
import zh_TC from './zh_TC/index'
import store from '@commonProject/store'
import { createI18n } from 'vue-i18n/index'
import enLocale from 'element-plus/lib/locale/lang/en'
import zhLocale from 'element-plus/lib/locale/lang/zh-cn'
import zhTwLocale from 'element-plus/lib/locale/lang/zh-tw'
import zhCNTable from 'vxe-table/es/locale/lang/zh-CN'
import enUSTable from 'vxe-table/es/locale/lang/en-US'
import zhTCTable from 'vxe-table/es/locale/lang/zh-TC'

const messages = {
  en: {
    ...en,
    ...enLocale,
    ...enUSTable,
  },
  zh_CN: {
    ...zh_CN,
    ...zhLocale,
    ...zhCNTable,
  },
  zh_TC: {
    ...zh_TC,
    ...zhTwLocale,
    ...zhTCTable,
  },
}

function getLanguage() {
  return store.getters['user/language'] || 'zh_CN'
}

const i18n = createI18n({
  locale: getLanguage(),
  messages,
})

export default i18n
